package com.example.demo.controller;


import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.entify.Feedback;
import com.example.demo.entify.Menu;
import com.example.demo.result.Result;
import com.example.demo.result.ResultFactory;
import com.example.demo.service.aboveProblemsService;
import com.example.demo.service.feedBackService;

@RestController
@CrossOrigin
@RequestMapping("/feedBack")
public class feedBackController {
	@Autowired	
	private feedBackService feedBackService;
	@Autowired
	private aboveProblemsService aboveProblemsService;
	@PostMapping("/addfeedBackRate")
	  public Result addfeedBack(@RequestBody Feedback feedback) {
		Integer ProblemId = feedback.getProblemId();
		
		feedback.setTime(new Date());
		int j = aboveProblemsService.updatePromState3(ProblemId);		
		int i=feedBackService.addFeedBack(feedback);
					  			 
		 return i>0? ResultFactory.buildSuccessFactory(true):ResultFactory.buildFailFactory("反馈失败");
		  
	  }
	
	@GetMapping("showRate")
	
	public Result showRate(Integer orderId) {
			
			Feedback showRate = feedBackService.showRate(orderId);
			
			return ResultFactory.buildSuccessFactory(showRate);
		
	}
	
	
	
	
	
	

}
